package com.cortext.pineapple.link;

import com.cortex.pineapple.fetch.RequestData.SOURCE_TYPE;

import android.graphics.Bitmap;


public abstract class Link {

	protected String id,title,url;
	protected Bitmap icon;
	protected OnDataChangedListener onDataChangedListener;

	public Link() {

	}
	public Link(String id,String title, String url) {
		this.id = id;
		this.title = title;
		this.url = url;
	}
	public Link(String id,String title, String url,Bitmap icon) {
		this.id = id;
		this.title = title;
		this.url = url;
		this.icon = icon;
	}

	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
		if(onDataChangedListener != null){
			onDataChangedListener.dataChanged(this);
		}
	}
	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
		if(onDataChangedListener != null){
			onDataChangedListener.dataChanged(this);
		}
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
		if(onDataChangedListener != null){
			onDataChangedListener.dataChanged(this);
		}
	}
	public Bitmap getIcon() {
		return icon;
	}
	public void setIcon(Bitmap icon) {
		this.icon = icon;
		if(onDataChangedListener != null){
			onDataChangedListener.dataChanged(this);
		}
	}
	public void setOnDataChangedListener(OnDataChangedListener onDataChangedListener) {
		this.onDataChangedListener = onDataChangedListener;
	}
	public abstract SOURCE_TYPE getSourceType();
	public interface OnDataChangedListener{
		void dataChanged(Link link);
	}
	@Override
	public String toString() {
		return "Link [id=" + id + ", title=" + title + ", url=" + url + "]";
	}
//	public static Link buildLink(String message){
//		String[] link = message.split(SEPARATOR);
//		return new Link(link[0],link[1],link[1]);
//	}
//	public static String buildMessage(Link link){
//		return link.getId()  + SEPARATOR + link.getTitle()  + SEPARATOR + link.getUrl();
//	}
}
